package cn.itcast.anli.web;

import cn.itcast.anli.service.EmployeeService;
import cn.itcast.anli.service.impl.EmployeeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delSelectedServlet")
public class DelSelectedServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取被选中的数据的id数组
        String[] cbs = request.getParameterValues("cb");
        //将数组传递给service
        EmployeeService service = new EmployeeServiceImpl();
        service.delSelected(cbs);
        //重定向回列表页面
        response.sendRedirect(request.getContextPath()+"/findEmpByPageServlet");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
